<?php
namespace app\api\controller;

use think\Lang;
use think\Response;

class Index
{

    public function lang() {
        $callback = input('callback');
        $modulename = input("modulename");
        $controllername = input("controllername");
        $language = input("language") ?: Lang::detect();

        Lang::load(APP_PATH . $modulename . '/lang/' . $language . '.php');
        Lang::load(APP_PATH . $modulename . '/lang/' . $language . '/' . $controllername . '.php');
        $type = $callback ? 'jsonp' : 'json';
        return Response::create(Lang::get(), $type, 200);
    }

    public function qrcode() {
        $identify = request()->param('identify');
        $txt = url('/member/member/auth/auth',['identify'=>$identify],false,true);
        $qrCode = new \Endroid\QrCode\QrCode($txt);
        header('Content-Type: '.$qrCode->getContentType());
        $qrCode->render();
    }

    public function qrcode2() {
        $identify = request()->param('identify');
        $txt = url('/', ['identify'=>$identify], false, config('branch.control'));
        $qrCode = new \Endroid\QrCode\QrCode($txt);
        header('Content-Type: '.$qrCode->getContentType());
        $qrCode->render();
    }

    public function test() {}
}